package com.xdja.myapplication

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import kotlinx.android.synthetic.main.activity_constraint_layout.*
import kotlinx.android.synthetic.main.activity_constraint_layout.placeholder

class ConstraintLayoutActivity : AppCompatActivity(), View.OnClickListener {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_constraint_layout)
        basic.setOnClickListener(this)
        radius.setOnClickListener(this)
        chain.setOnClickListener(this)
        guideline.setOnClickListener(this)
        barrier.setOnClickListener(this)
        placeholder.setOnClickListener(this)
        group.setOnClickListener(this)
        ratio.setOnClickListener(this)
        layer.setOnClickListener(this)
        flow.setOnClickListener(this)
        helper.setOnClickListener(this)
        helper1.setOnClickListener(this)
        helper2.setOnClickListener(this)
        animate.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        if (v!!.id==animate.id) {
            startActivity(Intent(this,ConstraintAnimActivity::class.java))
            return
        }
        var layoutId = when (v.id) {
            basic.id -> R.layout.activity_constraint_basic
            radius.id -> R.layout.activity_constraint_circle_radius
            chain.id -> R.layout.activity_constraint_chain
            guideline.id -> R.layout.activity_constraint_guideline
            barrier.id -> R.layout.activity_constraint_barrier
            group.id -> R.layout.activity_constraint_circle_group
            placeholder.id -> R.layout.activity_constraint_placeholder
            ratio.id -> R.layout.activity_constraint_ration
            layer.id -> R.layout.activity_constraint_layer
            flow.id -> R.layout.activity_constraint_flow
            helper.id -> R.layout.activity_constraint_helper
            helper1.id -> R.layout.activity_constraint_helper1
            helper2.id -> R.layout.activity_constraint_helper2
            else -> R.layout.activity_constraint_basic
        }
        val intent = Intent(this, LayoutDemoActivity::class.java)
        intent.putExtra("layoutId", layoutId)
        startActivity(intent)
    }
}
